package com.pattern.design.designpattern.databind;


import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import java.util.List;

public class MyViewModel extends ViewModel {
    private MutableLiveData<Integer> number;
    private MutableLiveData<List<UserBean>> datalist;
    private MutableLiveData<UserBean> userBean;


    public MutableLiveData<Integer> getNumber() {
        if (number == null) {
            number = new MutableLiveData<>();
            number.setValue(0);
        }
        return number;
    }

    public MutableLiveData<List<UserBean>> getDatalist() {
        if (datalist == null) {
            datalist = new MutableLiveData<>();
        }
        return datalist;
    }

    public MutableLiveData<UserBean> getUserBean() {
        if (userBean == null) {
            userBean = new MutableLiveData<>();
        }
        return userBean;
    }

    public void add() {
        number.setValue(number.getValue() + 1);
    }

    public void addList() {
//        datalist.setValue(datalist.getValue().add());
    }
}
